<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>GEN23</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GEN21.html" title="GEN21" />
    <link rel="next" href="GEN24.html" title="GEN24" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN23</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN21.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN24.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="GEN23"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN23" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN23</span>
        </h2>
        <p>GEN23 — 
      Reads numeric values from a text file.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215091088"></a>
        <h2>Description</h2>
        <p>
      This subroutine reads numeric values from an external ASCII file.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215135072"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size -23 "filename.txt"</pre>
      </div>
      <div class="refsect1">
        <a id="idp215137104"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>"filename.txt"</em></span> -- numeric values contained in "filename.txt" (which indicates the complete pathname of the character file to be read), can be separated by spaces, tabs, newline characters or commas.
    </p>
        <p>
      <span class="emphasis"><em>size</em></span> -- number of points in the table. Must be a power of 2 , power of 2 + 1, or zero.  If <span class="emphasis"><em>size</em></span> = 0, table size is determined by the number of numeric values in <span class="emphasis"><em>filename.txt</em></span>. (New in Csound version 3.57)
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        All characters following ';', '#' (comment) or '&lt;' (XML
        tag from version 6.04) are ignored until next line (numbers too).
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp215142544"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the GEN23 opcode. It uses the file <a class="ulink" href="examples/gen23.csd" target="_top"><em class="citetitle">gen23.csd</em></a> and <a class="ulink" href="examples/spectrum.txt" target="_top"> <em class="citetitle">spectrum.txt</em></a>.
           </p>
        <div class="example">
          <a id="idp215145376"></a>
          <p class="title">
            <strong>Example 1112. Example of the GEN23 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o gen23.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1
<span class="comment">;"spectrum.txt" is created by the spectrum plotter of Audacity (set at size 128), using "fox.wav".</span>

<span class="oblock">instr</span> 1	<span class="comment">;performs additive synthesis based on spectrum.txt</span>

indx <span class="op">=</span>0						<span class="comment">;start reading at first value</span>
<span class="olabel">loop</span><span class="op">:</span>
ifreq <span class="opc">tab_i</span> indx, 2				<span class="comment">;take odd values of list (= frequency)</span>
iamp <span class="opc">tab_i</span> indx<span class="op">+</span>1, 2				<span class="comment">;take even values of list (= amplitude)</span>
<span class="opc">event_i</span> "i", 10, 0, p3, iamp, ifreq   		<span class="comment">;use "event_i" to trigger instr. 10 </span>
    <span class="octrl">loop_lt</span> indx, 2, 128, <span class="olabel">loop</span>			<span class="comment">;use all 128 frequency and amplitude values</span>

<span class="oblock">endin</span>

<span class="oblock">instr</span> 10 <span class="comment">;generate sound</span>

iamp  <span class="op">=</span> p4
ifreq <span class="op">=</span> p5
asig  <span class="opc">poscil</span> <span class="opc">ampdb</span>(iamp), ifreq, 1
asig  <span class="opc">linen</span> asig, .01, p3, p2
      <span class="opc">outs</span>  asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 16384 10 1		<span class="comment">;sine wave</span>
<span class="stamnt">f</span> 2 0 128 -23 "spectrum.txt"	<span class="comment">;"spectrum.txt" can be found in /manual/examples</span>

<span class="stamnt">i</span>1 0 2

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />  
        <span class="phrase">This is the diagram of the waveform of the GEN23 routine, as used in the example:</span>

      </p>
        <div class="mediaobject">
          <img src="images/gen23.png" alt="f 2 0 128 -23 &quot;spectrum.txt&quot; - not normalized" />
          <div class="caption">
            <p>f 2 0 128 -23 "spectrum.txt" - not normalized</p>
          </div>
        </div>
        <p>
   
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215153696"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Gabriel Maldonado</td>
          </tr>
          <tr>
            <td>Italy</td>
          </tr>
          <tr>
            <td>February, 1998</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.47. Comments starting with '#' are
    ignored from Csound version 5.12.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN21.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="GEN24.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN21 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN24</td>
        </tr>
      </table>
    </div>
  </body>
</html>
